package com.gxa.service.parking.impl;



import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.parking.PSpaceSearchDto;
import com.gxa.dto.parking.ParkingSpacesDto;
import com.gxa.entity.parking.PRegion;
import com.gxa.entity.parking.Parking;
import com.gxa.entity.parking.ParkingSpaces;
import com.gxa.mapper.parking.ParkingSpacesMapper;
import com.gxa.service.parking.ParkingSpacesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-11 10:05:39
 */
@Service
public class ParkingSpacesServiceImpl extends ServiceImpl<ParkingSpacesMapper, ParkingSpaces> implements ParkingSpacesService {
    @Autowired
    private ParkingSpacesMapper parkingSpacesMapper;

    @Override
    public PageInfo<ParkingSpacesDto> selectAll(PSpaceSearchDto pSpaceSearchDto,Integer pageNum,Integer pageSize) {

        PageHelper.startPage(pageNum, pageSize);
        List<ParkingSpacesDto> parkingSpacesDtos = parkingSpacesMapper.queryAll(pSpaceSearchDto);
        PageInfo<ParkingSpacesDto> parkingSpacesDtoPageInfo = new PageInfo<>(parkingSpacesDtos);
        return parkingSpacesDtoPageInfo;
    }

    @Override
    public ParkingSpacesDto selectByid(Integer id) {
        ParkingSpacesDto parkingSpacesDto = parkingSpacesMapper.queryById(id);
        return parkingSpacesDto;
    }

    @Override
    public void add(ParkingSpaces parkingSpaces) {
        parkingSpacesMapper.insert(parkingSpaces);
    }

    @Override
    public List<Parking> queryParking() {
        List<Parking> parkings = parkingSpacesMapper.queryParking();
        return parkings;
    }

    @Override
    public List<PRegion> queryPRegion(String parkingNum) {
        List<PRegion> pRegions = parkingSpacesMapper.queryPRegion(parkingNum);
        return pRegions;
    }

    @Override
    public void update(ParkingSpaces parkingSpaces) {
        parkingSpacesMapper.updateById(parkingSpaces);
    }

    @Override
    public void deleteById(Integer id) {
        parkingSpacesMapper.deleteById(id);
    }
}
